package rus.sq.osTicket.Mobile;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;

public class NDListViewAdapter extends ArrayAdapter<String>{
    private final Context context;
    private final String[] mTitles;
    private final String[] mDescription;

    public NDListViewAdapter(Context context, String[] lviTitles, String[] lviDescription) {
        super(context, R.layout.nd_listview_item,lviTitles);
        this.context = context;
        this.mTitles = lviTitles;
        this.mDescription = lviDescription;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.nd_listview_item,parent,false);

        ImageView imageView = (ImageView)rowView.findViewById(R.id.nd_lvi_imageview);
        TextView txt1 = (TextView)rowView.findViewById(R.id.nd_lvi_textview1);
        TextView txt2 = (TextView)rowView.findViewById(R.id.nd_lvi_textview2);
        txt1.setText(mTitles[position]);
        txt2.setText(mDescription[position]);
        switch (position){
            case 0:
                imageView.setImageResource(R.drawable.nd_viewticket);
                break;
            case 1:
                imageView.setImageResource(R.drawable.nd_addticket);
                break;
            case 2:
                imageView.setImageResource(R.drawable.nd_findticket);
                break;
            case 3:
                imageView.setImageResource(R.drawable.nd_about);
                break;
            default:
                break;
        }
        return rowView;
    }


}
